import request from '@/utils/request'
import qs from 'qs'

// 查询套餐审核列表
export function listAudit(query) {
  return request({
    url: '/workflow/audit/list',
    method: 'get',
    params: query
  })
}

// 查询流程进度
export function getProcessingImage(instanceId) {
	return request({
		url: '/workflow/audit/processing/image',
		params: {instanceId},
		method: 'get'
	})
}

// 审批功能
export function doAudit(params) {
	let formParams = qs.stringify(params, {indices: false});

	return request({
		url: '/workflow/audit/doAudit',
		data: formParams,
		headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
		method: 'post'
	})
}

// 开始审核
export function startAudit(id, info) {
  let params = {id, info}
  let formParams = qs.stringify(params, {indices: false});

  return request({
    url: '/workflow/audit/audit',
    data: formParams,
    headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
    method: 'post'
  })
}

// 重新审核
export function reapply(params) {
	let formParams = qs.stringify(params, {indices: false});

	return request({
		url: '/workflow/audit/reapply',
		data: formParams,
		headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
		method: 'post'
	})
}

// 撤销审核
export function cancel(id, reason) {
	let params = {id, reason}
	let formParams = qs.stringify(params, {indices: false});

	return request({
		url: '/workflow/audit/cancel',
		data: formParams,
		headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
		method: 'post'
	})
}
